﻿Public Class TraCuuBV
    Inherits DataProvider

    Public Function dtload() As DataSet
        Dim sql As String = "SELECT MuaVe.id, HanhKhach.HoTen, ChuyenBay_HangVe.ChuyenBay, HangVe.Ten AS TenHV, MuaVe.NgayMua, MuaVe.GiaVe " +
        "FROM HanhKhach INNER JOIN (HangVe INNER JOIN (ChuyenBay_HangVe INNER JOIN MuaVe ON ChuyenBay_HangVe.ID = MuaVe.ChuyenBay_HangVe) " +
        "ON HangVe.ID = ChuyenBay_HangVe.HangVe) ON HanhKhach.id = MuaVe.HanhKhach"
        Return Me.GetDT(sql)
    End Function

    Public Function find(ByVal dto As DTO.TraCuuBV) As DataSet
        Dim sql As String = "SELECT MuaVe.id, HanhKhach.HoTen, ChuyenBay_HangVe.ChuyenBay, HangVe.Ten AS TenHV, MuaVe.NgayMua, MuaVe.GiaVe " +
        "FROM HanhKhach INNER JOIN (HangVe INNER JOIN (ChuyenBay_HangVe INNER JOIN MuaVe ON ChuyenBay_HangVe.ID = MuaVe.ChuyenBay_HangVe) " +
        "ON HangVe.ID = ChuyenBay_HangVe.HangVe) ON HanhKhach.id = MuaVe.HanhKhach " +
        "WHERE HanhKhach.HoTen LIKE '%" + dto.hotenhk + "%' AND ChuyenBay_HangVe.ChuyenBay LIKE '%" + dto.macb + "%' AND MuaVe.NgayMua BETWEEN #" + dto.ngaybd.ToString("MM/dd/yyyy") + "# AND #" + dto.ngaykt.ToString("MM/dd/yyyy") + "#"
        Return Me.GetDT(sql)
    End Function
End Class
